package com.sl.au.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.SalemanMobilize;
import com.sl.au.repository.SalemanMobilizeRepository;
import com.sl.au.service.SalemanMobilizeService;

/**
 * 销售人员管理接口
 * @author HXZ
 *
 */
@Service("SalemanMobilizeService")
@Transactional
public class SalemanMobilizeServiceImpl extends BaseServiceImpl implements SalemanMobilizeService {

	@Autowired
	SalemanMobilizeRepository salemanMobilizeRepository;
	
	public SalemanMobilizeRepository getRepository(){
		return this.salemanMobilizeRepository;
	}
	
	@Override
	public List<SalemanMobilize> getPage(int start, int length, String key, String orderName, String dir) {
		Page<SalemanMobilize> pages=null;
		Pageable pageable=new PageRequest(start/length,length,Sort.Direction.DESC,"id");
		pages=salemanMobilizeRepository.findAll(pageable);
		return pages.getContent();
	}
	
	@Override
	public List<SalemanMobilize> getSalemanMobilizes(int start, int length, String key, String orderName, String dir) {
		Page<SalemanMobilize> pages=null;
		Pageable pageable=new PageRequest(start/length,length,Sort.Direction.DESC,"id");
		pages=salemanMobilizeRepository.getSalemanMobilizes(key,pageable);
		return pages.getContent();
	}

}
